﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E.Web.UI.Page;
using E.Model;
using E.BLL;
using X.Common;
using E.Enum;
using X.Pager;
using X.Pager.List;

namespace E.Web.Teacher.internals.exam
{
    public partial class PaperList : TeacherBasePage
    {
        public Dictionary<int, string> certificateList;
        public IList<DictAreaModel> areaList;
        public string username;
        public string email;
        public string loginid;
        public int areaid;
        public int currentCertificateID;//项目ID
        public int courseid;//课程ID
        public string examtitle;//试卷名称
        public IList<PaperInspectModel> paperList;
       

        public string act;

        protected override void ShowPage()
        {
            ExamBLL bll = new ExamBLL();
            areaList = GetTeacherAreaList(teacherid);
            act = XRequest.GetString("act");

            switch (authority)
            {
                case EnumTeacherAuthority.Internals:
                    certificateList = (new TeacherBLL()).GetTeacherProjectInfo(teacherid);
                    break;
                case EnumTeacherAuthority.Normal:
                    certificateList = (new CourseBLL()).GetCertificateList();
                    break;
                case EnumTeacherAuthority.Admin:
                    certificateList = (new CourseBLL()).GetAllCertificateAndProjectList();
                    break;
                default: break;
            }

            //relationid = XRequest.GetInt("RelationSlt", -1);

            courseid = XRequest.GetInt("CourseSlt", -1);
            currentCertificateID = XRequest.GetInt("CertificateSlt", -1);
            username = XRequest.GetString("UserNameTxt");
            email = XRequest.GetString("EmailTxt");
            loginid = XRequest.GetString("LoginIDTxt");
            areaid = XRequest.GetInt("AreaSlt",-1);
            examtitle = XRequest.GetString("ExamTitle");


            if (ispost || act == "s")
            {
                SearchExamModel searchModel = new SearchExamModel();
                searchModel.userName = username;
                searchModel.email = email;
                searchModel.loginid = loginid;
                searchModel.AreaID = areaid;
                searchModel.CertificateID = currentCertificateID;
                searchModel.CourseCertificateID = courseid;
                searchModel.Title = examtitle;

                PaperInspectListModel listModel = new PaperInspectListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = bll.GetPaperInspectListModelByCondition(searchModel, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    paperList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("CertificateSlt", currentCertificateID.ToString());
                    parms.Add("CourseSlt", courseid.ToString());
                    //parms.Add("RelationSlt", relationid.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
        }
    }
}